/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/15
\**********************/
#include "LuaListContainerElement.h"

#define CObjPtr ((CListContainerElementUI*)m_cobj)

namespace DuiLib {

int LuaListContainerElement::GetIndex()
{
    return CObjPtr->GetIndex();
}

void LuaListContainerElement::SetIndex(int iIndex)
{
    CObjPtr->SetIndex(iIndex);
}

int LuaListContainerElement::GetOwner(LuaState *L)
{
    IListOwnerUI* ctrl = CObjPtr->GetOwner();
    LuaHelperNS::PushCObj(L, ctrl);
    return 1;
}

void LuaListContainerElement::SetVisible(bool bVisible)
{
    CObjPtr->SetVisible(bVisible);
}

void LuaListContainerElement::SetEnabled(bool bEnable)
{
    CObjPtr->SetEnabled(bEnable);
}

bool LuaListContainerElement::IsSelected()
{
    return CObjPtr->IsSelected();
}

bool LuaListContainerElement::Select(bool bSelect)
{
    return CObjPtr->Select(bSelect);
}

bool LuaListContainerElement::SelectMulti(bool bSelect)
{
    return CObjPtr->SelectMulti(bSelect);
}

bool LuaListContainerElement::IsExpanded()
{
    return CObjPtr->IsExpanded();
}

bool LuaListContainerElement::Expand(bool bExpand)
{
    return CObjPtr->Expand(bExpand);
}

void LuaListContainerElement::Invalidate()
{
    CObjPtr->Invalidate();
}

bool LuaListContainerElement::Activate()
{
    return CObjPtr->Activate();
}

int LuaListContainerElement::SetPos(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->SetPos(rc, bNeedInvalidate);
    return 0;
}

SDLUA_BEGIN_REGISTER(LuaListContainerElement, ListContainerElement, HorizontalLayout)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, GetIndex, GetIndex)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, SetIndex, SetIndex)
    SDLUA_REGISTER_FUN_LUA(LuaListContainerElement, GetOwner, GetOwner)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, SetVisible, SetVisible)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, SetEnabled, SetEnabled)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, IsSelected, IsSelected)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, Select, Select)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, SelectMulti, SelectMulti)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, IsExpanded, IsExpanded)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, Expand, Expand)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, Invalidate, Invalidate)
    SDLUA_REGISTER_FUN_CPP(LuaListContainerElement, Activate, Activate)
    SDLUA_REGISTER_FUN_LUA(LuaListContainerElement, SetPos, SetPos)
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaListContainerElement, ListContainerElement)
SDLUA_END_UNREGISTER(ListContainerElement)

}

#undef CObjPtr